package com.hckj.jianzhijia.popupwindows;

import android.content.Context;
import android.view.View;

import com.hckj.jianzhijia.model.Region;
import com.hckj.jianzhijia.utils.Data;

import java.util.ArrayList;

/**
 * Created by 赵奇隆 on 2015-10-29.
 */
public class PublishPopupWindowRegion  extends ListPopupWindow {

    private PublishPopWinRegionInterface publishPopWinRegionInterface;
    private ArrayList<Region> regions;

    public static PublishPopupWindowRegion newInstance(Context context,PublishPopWinRegionInterface publishPopWinRegionInterface, View parentView,ArrayList<Region> regions){
        String[] data = new String[regions.size()];
        for(int i=0,j=regions.size();i<j;i++){
            data[i] = regions.get(i).getRegion();
        }
        return  new PublishPopupWindowRegion(context, publishPopWinRegionInterface, parentView, regions, data);
    }


    public PublishPopupWindowRegion(Context context,PublishPopWinRegionInterface publishPopWinRegionInterface, View parentView,ArrayList<Region> regions,String[] data) {
        super(context, parentView, null, data);
        this.publishPopWinRegionInterface = publishPopWinRegionInterface;
        this.regions = regions;
    }



    public  interface PublishPopWinRegionInterface{
        public void setRegion(int position,String itemName);
    }

    @Override
    public void getListItem(int position, String itemName) {
        publishPopWinRegionInterface.setRegion(regions.get(position).getRegionId(), itemName);
    }
}
